Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d72f5c

Browse files
committed
fixes BufferedImage, FontDesignMetrics, StandardGlyphVector
BufferedImage misplaces bytes going to agr byte format.FontDesignMetrics and JSToolkit should not round font metrics comingfrom JavaScript TextMetricsStandardGlyphVector should be able to at least create outline andlogical bounds. This now works to high precision.
1 parent40e4fbf commit8d72f5c

File tree

6 files changed

+363
-197
lines changed

6 files changed

+363
-197
lines changed
1.54 KB
Binary file not shown.

‎sources/net.sf.j2s.java.core/src/java/awt/Font.java‎

Lines changed: 136 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
importstaticsun.font.EAttribute.EWIDTH;
5454

5555
importjava.awt.font.FontRenderContext;
56+
importjava.awt.font.GlyphVector;
5657
importjava.awt.font.LineMetrics;
5758
importjava.awt.font.TextAttribute;
5859
importjava.awt.font.TextLayout;
@@ -65,13 +66,16 @@
6566
importjava.text.CharacterIterator;
6667
importjava.util.Map;
6768

69+
importcom.sun.javafx.text.GlyphLayout;
70+
6871
importjavajs.util.SB;
6972
importsun.font.AttributeMap;
7073
importsun.font.AttributeValues;
7174
importsun.font.CoreMetrics;
7275
importsun.font.Font2DHandle;
7376
importsun.font.FontDesignMetrics;
7477
importsun.font.FontLineMetrics;
78+
importsun.font.StandardGlyphVector;
7579
importswingjs.JSToolkit;
7680

7781
/**
@@ -2578,139 +2582,139 @@ public Rectangle2D getMaxCharBounds(FontRenderContext frc) {
25782582
metrics[0] +metrics[1] +metrics[2]);
25792583
}
25802584

2581-
//// /**
2582-
//// * Creates a {@link java.awt.font.GlyphVector GlyphVector} by
2583-
//// * mapping characters to glyphs one-to-one based on the
2584-
//// * Unicode cmap in this <code>Font</code>. This method does no other
2585-
//// * processing besides the mapping of glyphs to characters. This
2586-
//// * means that this method is not useful for some scripts, such
2587-
//// * as Arabic, Hebrew, Thai, and Indic, that require reordering,
2588-
//// * shaping, or ligature substitution.
2589-
//// * @param frc the specified <code>FontRenderContext</code>
2590-
//// * @param str the specified <code>String</code>
2591-
//// * @return a new <code>GlyphVector</code> created with the
2592-
//// * specified <code>String</code> and the specified
2593-
//// * <code>FontRenderContext</code>.
2594-
//// */
2595-
//// public GlyphVector createGlyphVector(FontRenderContext frc, String str)
2596-
//// {
2597-
//// return (GlyphVector)new StandardGlyphVector(this, str, frc);
2598-
//// }
2599-
////
2600-
//// /**
2601-
//// * Creates a {@link java.awt.font.GlyphVector GlyphVector} by
2602-
//// * mapping characters to glyphs one-to-one based on the
2603-
//// * Unicode cmap in this <code>Font</code>. This method does no other
2604-
//// * processing besides the mapping of glyphs to characters. This
2605-
//// * means that this method is not useful for some scripts, such
2606-
//// * as Arabic, Hebrew, Thai, and Indic, that require reordering,
2607-
//// * shaping, or ligature substitution.
2608-
//// * @param frc the specified <code>FontRenderContext</code>
2609-
//// * @param chars the specified array of characters
2610-
//// * @return a new <code>GlyphVector</code> created with the
2611-
//// * specified array of characters and the specified
2612-
//// * <code>FontRenderContext</code>.
2613-
//// */
2614-
//// public GlyphVector createGlyphVector(FontRenderContext frc, char[] chars)
2615-
//// {
2616-
//// return (GlyphVector)new StandardGlyphVector(this, chars, frc);
2617-
//// }
2618-
////
2619-
//// /**
2620-
//// * Creates a {@link java.awt.font.GlyphVector GlyphVector} by
2621-
//// * mapping the specified characters to glyphs one-to-one based on the
2622-
//// * Unicode cmap in this <code>Font</code>. This method does no other
2623-
//// * processing besides the mapping of glyphs to characters. This
2624-
//// * means that this method is not useful for some scripts, such
2625-
//// * as Arabic, Hebrew, Thai, and Indic, that require reordering,
2626-
//// * shaping, or ligature substitution.
2627-
//// * @param frc the specified <code>FontRenderContext</code>
2628-
//// * @param ci the specified <code>CharacterIterator</code>
2629-
//// * @return a new <code>GlyphVector</code> created with the
2630-
//// * specified <code>CharacterIterator</code> and the specified
2631-
//// * <code>FontRenderContext</code>.
2632-
//// */
2633-
//// public GlyphVector createGlyphVector( FontRenderContext frc,
2634-
//// CharacterIterator ci)
2635-
//// {
2636-
//// return (GlyphVector)new StandardGlyphVector(this, ci, frc);
2637-
//// }
2638-
////
2639-
//// /**
2640-
//// * Creates a {@link java.awt.font.GlyphVector GlyphVector} by
2641-
//// * mapping characters to glyphs one-to-one based on the
2642-
//// * Unicode cmap in this <code>Font</code>. This method does no other
2643-
//// * processing besides the mapping of glyphs to characters. This
2644-
//// * means that this method is not useful for some scripts, such
2645-
//// * as Arabic, Hebrew, Thai, and Indic, that require reordering,
2646-
//// * shaping, or ligature substitution.
2647-
//// * @param frc the specified <code>FontRenderContext</code>
2648-
//// * @param glyphCodes the specified integer array
2649-
//// * @return a new <code>GlyphVector</code> created with the
2650-
//// * specified integer array and the specified
2651-
//// * <code>FontRenderContext</code>.
2652-
//// */
2653-
//// public GlyphVector createGlyphVector( FontRenderContext frc,
2654-
//// int [] glyphCodes)
2655-
//// {
2656-
//// return (GlyphVector)new StandardGlyphVector(this, glyphCodes, frc);
2657-
//// }
2658-
////
2659-
//// /**
2660-
//// * Returns a new <code>GlyphVector</code> object, performing full
2661-
//// * layout of the text if possible. Full layout is required for
2662-
//// * complex text, such as Arabic or Hindi. Support for different
2663-
//// * scripts depends on the font and implementation.
2664-
//// * <p>
2665-
//// * Layout requires bidi analysis, as performed by
2666-
//// * <code>Bidi</code>, and should only be performed on text that
2667-
//// * has a uniform direction. The direction is indicated in the
2668-
//// * flags parameter,by using LAYOUT_RIGHT_TO_LEFT to indicate a
2669-
//// * right-to-left (Arabic and Hebrew) run direction, or
2670-
//// * LAYOUT_LEFT_TO_RIGHT to indicate a left-to-right (English)
2671-
//// * run direction.
2672-
//// * <p>
2673-
//// * In addition, some operations, such as Arabic shaping, require
2674-
//// * context, so that the characters at the start and limit can have
2675-
//// * the proper shapes. Sometimes the data in the buffer outside
2676-
//// * the provided range does not have valid data. The values
2677-
//// * LAYOUT_NO_START_CONTEXT and LAYOUT_NO_LIMIT_CONTEXT can be
2678-
//// * added to the flags parameter to indicate that the text before
2679-
//// * start, or after limit, respectively, should not be examined
2680-
//// * for context.
2681-
//// * <p>
2682-
//// * All other values for the flags parameter are reserved.
2683-
//// *
2684-
//// * @param frc the specified <code>FontRenderContext</code>
2685-
//// * @param text the text to layout
2686-
//// * @param start the start of the text to use for the <code>GlyphVector</code>
2687-
//// * @param limit the limit of the text to use for the <code>GlyphVector</code>
2688-
//// * @param flags control flags as described above
2689-
//// * @return a new <code>GlyphVector</code> representing the text between
2690-
//// * start and limit, with glyphs chosen and positioned so as to best represent
2691-
//// * the text
2692-
//// * @throws ArrayIndexOutOfBoundsException if start or limit is
2693-
//// * out of bounds
2694-
//// * @see java.text.Bidi
2695-
//// * @see #LAYOUT_LEFT_TO_RIGHT
2696-
//// * @see #LAYOUT_RIGHT_TO_LEFT
2697-
//// * @see #LAYOUT_NO_START_CONTEXT
2698-
//// * @see #LAYOUT_NO_LIMIT_CONTEXT
2699-
//// * @since 1.4
2700-
//// */
2701-
//// public GlyphVector layoutGlyphVector(FontRenderContext frc,
2702-
//// char[] text,
2703-
//// int start,
2704-
//// int limit,
2705-
//// int flags) {
2706-
////
2707-
//// GlyphLayout gl = GlyphLayout.get(null); // !!! no custom layout engines
2708-
//// StandardGlyphVector gv = gl.layout(this, frc, text,
2709-
//// start, limit-start, flags, null);
2710-
//// GlyphLayout.done(gl);
2711-
//// return gv;
2712-
//// }
2585+
/**
2586+
* Creates a {@link java.awt.font.GlyphVector GlyphVector} by
2587+
* mapping characters to glyphs one-to-one based on the
2588+
* Unicode cmap in this <code>Font</code>. This method does no other
2589+
* processing besides the mapping of glyphs to characters. This
2590+
* means that this method is not useful for some scripts, such
2591+
* as Arabic, Hebrew, Thai, and Indic, that require reordering,
2592+
* shaping, or ligature substitution.
2593+
* @param frc the specified <code>FontRenderContext</code>
2594+
* @param str the specified <code>String</code>
2595+
* @return a new <code>GlyphVector</code> created with the
2596+
* specified <code>String</code> and the specified
2597+
* <code>FontRenderContext</code>.
2598+
*/
2599+
publicGlyphVectorcreateGlyphVector(FontRenderContextfrc,Stringstr)
2600+
{
2601+
return (GlyphVector)newStandardGlyphVector(this,str,frc);
2602+
}
2603+
2604+
/**
2605+
* Creates a {@link java.awt.font.GlyphVector GlyphVector} by
2606+
* mapping characters to glyphs one-to-one based on the
2607+
* Unicode cmap in this <code>Font</code>. This method does no other
2608+
* processing besides the mapping of glyphs to characters. This
2609+
* means that this method is not useful for some scripts, such
2610+
* as Arabic, Hebrew, Thai, and Indic, that require reordering,
2611+
* shaping, or ligature substitution.
2612+
* @param frc the specified <code>FontRenderContext</code>
2613+
* @param chars the specified array of characters
2614+
* @return a new <code>GlyphVector</code> created with the
2615+
* specified array of characters and the specified
2616+
* <code>FontRenderContext</code>.
2617+
*/
2618+
publicGlyphVectorcreateGlyphVector(FontRenderContextfrc,char[]chars)
2619+
{
2620+
return (GlyphVector)newStandardGlyphVector(this,chars,frc);
2621+
}
27132622

2623+
/**
2624+
* Creates a {@link java.awt.font.GlyphVector GlyphVector} by
2625+
* mapping the specified characters to glyphs one-to-one based on the
2626+
* Unicode cmap in this <code>Font</code>. This method does no other
2627+
* processing besides the mapping of glyphs to characters. This
2628+
* means that this method is not useful for some scripts, such
2629+
* as Arabic, Hebrew, Thai, and Indic, that require reordering,
2630+
* shaping, or ligature substitution.
2631+
* @param frc the specified <code>FontRenderContext</code>
2632+
* @param ci the specified <code>CharacterIterator</code>
2633+
* @return a new <code>GlyphVector</code> created with the
2634+
* specified <code>CharacterIterator</code> and the specified
2635+
* <code>FontRenderContext</code>.
2636+
*/
2637+
publicGlyphVectorcreateGlyphVector(FontRenderContextfrc,
2638+
CharacterIteratorci)
2639+
{
2640+
return (GlyphVector)newStandardGlyphVector(this,ci,frc);
2641+
}
2642+
2643+
/**
2644+
* Creates a {@link java.awt.font.GlyphVector GlyphVector} by
2645+
* mapping characters to glyphs one-to-one based on the
2646+
* Unicode cmap in this <code>Font</code>. This method does no other
2647+
* processing besides the mapping of glyphs to characters. This
2648+
* means that this method is not useful for some scripts, such
2649+
* as Arabic, Hebrew, Thai, and Indic, that require reordering,
2650+
* shaping, or ligature substitution.
2651+
* @param frc the specified <code>FontRenderContext</code>
2652+
* @param glyphCodes the specified integer array
2653+
* @return a new <code>GlyphVector</code> created with the
2654+
* specified integer array and the specified
2655+
* <code>FontRenderContext</code>.
2656+
*/
2657+
publicGlyphVectorcreateGlyphVector(FontRenderContextfrc,
2658+
int []glyphCodes)
2659+
{
2660+
return (GlyphVector)newStandardGlyphVector(this,glyphCodes,frc);
2661+
}
2662+
2663+
/**
2664+
* Returns a new <code>GlyphVector</code> object, performing full
2665+
* layout of the text if possible. Full layout is required for
2666+
* complex text, such as Arabic or Hindi. Support for different
2667+
* scripts depends on the font and implementation.
2668+
* <p>
2669+
* Layout requires bidi analysis, as performed by
2670+
* <code>Bidi</code>, and should only be performed on text that
2671+
* has a uniform direction. The direction is indicated in the
2672+
* flags parameter,by using LAYOUT_RIGHT_TO_LEFT to indicate a
2673+
* right-to-left (Arabic and Hebrew) run direction, or
2674+
* LAYOUT_LEFT_TO_RIGHT to indicate a left-to-right (English)
2675+
* run direction.
2676+
* <p>
2677+
* In addition, some operations, such as Arabic shaping, require
2678+
* context, so that the characters at the start and limit can have
2679+
* the proper shapes. Sometimes the data in the buffer outside
2680+
* the provided range does not have valid data. The values
2681+
* LAYOUT_NO_START_CONTEXT and LAYOUT_NO_LIMIT_CONTEXT can be
2682+
* added to the flags parameter to indicate that the text before
2683+
* start, or after limit, respectively, should not be examined
2684+
* for context.
2685+
* <p>
2686+
* All other values for the flags parameter are reserved.
2687+
*
2688+
* @param frc the specified <code>FontRenderContext</code>
2689+
* @param text the text to layout
2690+
* @param start the start of the text to use for the <code>GlyphVector</code>
2691+
* @param limit the limit of the text to use for the <code>GlyphVector</code>
2692+
* @param flags control flags as described above
2693+
* @return a new <code>GlyphVector</code> representing the text between
2694+
* start and limit, with glyphs chosen and positioned so as to best represent
2695+
* the text
2696+
* @throws ArrayIndexOutOfBoundsException if start or limit is
2697+
* out of bounds
2698+
* @see java.text.Bidi
2699+
* @see #LAYOUT_LEFT_TO_RIGHT
2700+
* @see #LAYOUT_RIGHT_TO_LEFT
2701+
* @see #LAYOUT_NO_START_CONTEXT
2702+
* @see #LAYOUT_NO_LIMIT_CONTEXT
2703+
* @since 1.4
2704+
*/
2705+
// public GlyphVector layoutGlyphVector(FontRenderContext frc,
2706+
// char[] text,
2707+
// int start,
2708+
// int limit,
2709+
// int flags) {
2710+
//
2711+
// GlyphLayout gl = GlyphLayout.get(null); // !!! no custom layout engines
2712+
// StandardGlyphVector gv = gl.layout(this, frc, text,
2713+
// start, limit-start, flags, null);
2714+
// GlyphLayout.done(gl);
2715+
// return gv;
2716+
// }
2717+
//
27142718
/**
27152719
* A flag to layoutGlyphVector indicating that text is left-to-right as
27162720
* determined by Bidi analysis.

‎sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,13 +2126,13 @@ private static void toIntARGB(byte[] ctxData, int[] iData, int alpha) {
21262126
}
21272127

21282128
privatevoidtoByteABGR(byte[]ctxData,byte[]buf) {
2129-
// convert canvas [r g b a r g b a ...] into [ b g r a b g r a b g ra...]
2129+
// convert canvas [r g b a r g b a ...] into [ab g r a b g r a b g r ...]
21302130
intn =ctxData.length;
21312131
for (inti =0,j =0;i <n;j +=4) {
2132+
buf[i++] =ctxData[j +3];
21322133
buf[i++] =ctxData[j +2];
21332134
buf[i++] =ctxData[j +1];
2134-
buf[i++] =ctxData[j];
2135-
buf[i++] =ctxData[j +3];
2135+
buf[i++] =ctxData[j +0];
21362136
}
21372137
}
21382138

‎sources/net.sf.j2s.java.core/src/sun/font/FontDesignMetrics.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ public int getDescent() {
509509
privatevoid_getMetrics() {
510510
if (ascent >=0)
511511
return;
512-
// 秘fm = new JSFontMetrics(font);
513512
ascent =JSFontMetrics.fontAscent(font);
514513
descent =JSFontMetrics.fontDescent(font);
515514
leading =JSFontMetrics.fontLeading(font);
@@ -568,7 +567,7 @@ public int getHeight() {
568567

569568
publicRectangle2D秘getStringBounds(Strings) {
570569
_getMetrics();
571-
returnnewRectangle2D.Float(0, -ascent,stringWidth(s),ascent +descent +leading);
570+
returnnewRectangle2D.Float(0, -ascent,getWidth(s),ascent +descent +leading);
572571
}
573572

574573
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp