mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-25 05:52:42 -08:00
Update Java part of Android port
* java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea, perform) (paintTo): * java/org/gnu/emacs/EmacsDrawLine.java (EmacsDrawLine): * java/org/gnu/emacs/EmacsDrawPoint.java (EmacsDrawPoint): * java/org/gnu/emacs/EmacsDrawRectangle.java (EmacsDrawRectangle) (paintTo): * java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable): * java/org/gnu/emacs/EmacsFillPolygon.java (EmacsFillPolygon): * java/org/gnu/emacs/EmacsFillRectangle.java (EmacsFillRectangle): * java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver): * java/org/gnu/emacs/EmacsGC.java (EmacsGC): * java/org/gnu/emacs/EmacsNative.java (EmacsNative): * java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap): * java/org/gnu/emacs/EmacsSdk23FontDriver.java (EmacsSdk23FontDriver): * java/org/gnu/emacs/EmacsSdk7FontDriver.java (EmacsSdk7FontDriver, textExtents1, textExtents, draw): * java/org/gnu/emacs/EmacsService.java (EmacsService, copyArea): * java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView): * java/org/gnu/emacs/EmacsView.java (EmacsView, onLayout) (onFocusChanged): * java/org/gnu/emacs/EmacsWindow.java (EmacsWindow, run) (resizeWindow, lockCanvas, getBitmap, onKeyDown, onKeyUp) (onActivityDetached): Move rendering to main thread. Make drawing operations completely static.
This commit is contained in:
parent
e816e57039
commit
695e26079e
17 changed files with 695 additions and 766 deletions
|
|
@ -20,9 +20,80 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
package org.gnu.emacs;
|
||||
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
|
||||
public class EmacsSdk23FontDriver extends EmacsSdk7FontDriver
|
||||
{
|
||||
private void
|
||||
textExtents1 (Sdk7FontObject font, int code, FontMetrics metrics,
|
||||
Paint paint, Rect bounds)
|
||||
{
|
||||
char[] text;
|
||||
|
||||
text = new char[2];
|
||||
text[0] = (char) code;
|
||||
text[1] = 'c';
|
||||
|
||||
paint.getTextBounds (text, 0, 1, bounds);
|
||||
|
||||
metrics.lbearing = (short) bounds.left;
|
||||
metrics.rbearing = (short) bounds.right;
|
||||
metrics.ascent = (short) -bounds.top;
|
||||
metrics.descent = (short) bounds.bottom;
|
||||
metrics.width
|
||||
= (short) paint.getRunAdvance (text, 0, 1, 0, 1, false, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void
|
||||
textExtents (FontObject font, int code[], FontMetrics fontMetrics)
|
||||
{
|
||||
int i;
|
||||
Paint paintCache;
|
||||
Rect boundsCache;
|
||||
Sdk7FontObject fontObject;
|
||||
char[] text;
|
||||
float width;
|
||||
|
||||
fontObject = (Sdk7FontObject) font;
|
||||
paintCache = fontObject.typeface.typefacePaint;
|
||||
paintCache.setTextSize (fontObject.pixelSize);
|
||||
boundsCache = new Rect ();
|
||||
|
||||
if (code.length == 0)
|
||||
{
|
||||
fontMetrics.lbearing = 0;
|
||||
fontMetrics.rbearing = 0;
|
||||
fontMetrics.ascent = 0;
|
||||
fontMetrics.descent = 0;
|
||||
fontMetrics.width = 0;
|
||||
}
|
||||
else if (code.length == 1)
|
||||
textExtents1 ((Sdk7FontObject) font, code[0], fontMetrics,
|
||||
paintCache, boundsCache);
|
||||
else
|
||||
{
|
||||
text = new char[code.length + 1];
|
||||
|
||||
for (i = 0; i < code.length; ++i)
|
||||
text[i] = (char) code[i];
|
||||
|
||||
text[code.length] = 'c';
|
||||
|
||||
paintCache.getTextBounds (text, 0, code.length,
|
||||
boundsCache);
|
||||
width = paintCache.getRunAdvance (text, 0, code.length, 0,
|
||||
code.length,
|
||||
false, code.length);
|
||||
|
||||
fontMetrics.lbearing = (short) boundsCache.left;
|
||||
fontMetrics.rbearing = (short) boundsCache.right;
|
||||
fontMetrics.ascent = (short) -boundsCache.top;
|
||||
fontMetrics.descent = (short) boundsCache.bottom;
|
||||
fontMetrics.width = (short) width;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int
|
||||
hasChar (FontSpec font, char charCode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue