ASF Bugzilla – Attachment 16041 Details for
Bug 36180
[PATCH] Test cases for font-family, font-style and font-weight
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
The patch to FontInfo and XMLRenderer
font-style-weight-tests.patch (text/plain), 4.20 KB, created by
Manuel Mall
on 2005-08-14 08:25:18 UTC
(
hide
)
Description:
The patch to FontInfo and XMLRenderer
Filename:
MIME Type:
Creator:
Manuel Mall
Created:
2005-08-14 08:25:18 UTC
Size:
4.20 KB
patch
obsolete
>Index: src/java/org/apache/fop/fonts/FontInfo.java >=================================================================== >--- src/java/org/apache/fop/fonts/FontInfo.java (revision 232570) >+++ src/java/org/apache/fop/fonts/FontInfo.java (working copy) >@@ -18,9 +18,13 @@ > > package org.apache.fop.fonts; > >-// Java >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.Iterator; >+import java.util.List; > import java.util.Map; > >+ > /** > * The FontInfo for the layout and rendering of a fo document. > * This stores the list of available fonts that are setup by >@@ -226,6 +230,61 @@ > usedFonts.put(fontName, fonts.get(fontName)); > return (FontMetrics)fonts.get(fontName); > } >+ >+ /** >+ * Returns the first triplet matching the given font name. >+ * As there may be multiple triplets matching the font name >+ * the result set is sorted first to guarantee consistent results. >+ * @param fontName The font name we are looking for >+ * @return The first triplet for the given font name >+ */ >+ private String getTripletFor(String fontName) { >+ List foundTriplets = new ArrayList(); >+ for (Iterator iter = triplets.entrySet().iterator(); iter.hasNext(); ) { >+ Map.Entry tripletEntry = (Map.Entry) iter.next(); >+ if (fontName.equals(((String)tripletEntry.getValue()))) { >+ foundTriplets.add(tripletEntry.getKey()); >+ } >+ } >+ if (foundTriplets.size() > 0) { >+ Collections.sort(foundTriplets); >+ return (String)foundTriplets.get(0); >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the font style for a particular font. >+ * There may be multiple font styles matching this font. Only the first >+ * found is returned. Searching is done on a sorted list to guarantee consistent >+ * results. >+ * @param fontName internal key >+ * @return font style >+ */ >+ public String getFontStyleFor(String fontName) { >+ String triplet = getTripletFor(fontName); >+ if (triplet != null) { >+ return triplet.substring(triplet.indexOf(',') + 1, triplet.lastIndexOf(',')); >+ } >+ return ""; >+ } >+ >+ /** >+ * Returns the font weight for a particular font. >+ * There may be multiple font weights matching this font. Only the first >+ * found is returned. Searching is done on a sorted list to guarantee consistent >+ * results. >+ * @param fontName internal key >+ * @return font weight >+ */ >+ public String getFontWeightFor(String fontName) { >+ String triplet = getTripletFor(fontName); >+ if (triplet != null) { >+ return triplet.substring(triplet.lastIndexOf(',') + 1); >+ } >+ return ""; >+ } >+ > } > > >Index: src/java/org/apache/fop/render/xml/XMLRenderer.java >=================================================================== >--- src/java/org/apache/fop/render/xml/XMLRenderer.java (revision 232570) >+++ src/java/org/apache/fop/render/xml/XMLRenderer.java (working copy) >@@ -68,6 +68,7 @@ > import org.apache.fop.area.inline.TextArea; > import org.apache.fop.fonts.FontSetup; > import org.apache.fop.fonts.FontInfo; >+import org.apache.fop.fonts.FontMetrics; > > /** > * Renderer that renders areas to XML for debugging purposes. >@@ -102,6 +103,9 @@ > /** The OutputStream to write the generated XML to. */ > protected OutputStream out; > >+ /** Font configuration */ >+ protected FontInfo fontInfo; >+ > /** > * Creates a new XML renderer. > */ >@@ -136,6 +140,7 @@ > * @param fontInfo the font info object to set up > */ > public void setupFontInfo(FontInfo fontInfo) { >+ this.fontInfo = fontInfo; > FontSetup.setup(fontInfo, null); > } > >@@ -272,6 +277,11 @@ > } > String value = traitEntry.getValue().toString(); > addAttribute(name, value); >+ if ("font-family".equals(name)) { >+ addAttribute("font-name", fontInfo.getMetricsFor(value).getFontName()); >+ addAttribute("font-style", fontInfo.getFontStyleFor(value)); >+ addAttribute("font-weight", fontInfo.getFontWeightFor(value)); >+ } > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 36180
:
16041
|
16042
|
16047