Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(51)

Delta Between Two Patch Sets: java/src/com/google/typography/font/tools/fontinfo/FontInfo.java

Issue 6463047: Added functions that provide information for block and glyph coverage (Closed) Base URL: http://sfntly.googlecode.com/svn/trunk/
Left Patch Set: Created 12 years, 7 months ago
Right Patch Set: Modified files according to code reviews Created 12 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | java/src/com/google/typography/font/tools/fontinfo/UnicodeBlockData.java » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2012 Google Inc. All Rights Reserved. 1 // Copyright 2012 Google Inc. All Rights Reserved.
2 2
3 package com.google.typography.font.tools.fontinfo; 3 package com.google.typography.font.tools.fontinfo;
4 4
5 import com.google.typography.font.sfntly.Font; 5 import com.google.typography.font.sfntly.Font;
6 import com.google.typography.font.sfntly.Font.MacintoshEncodingId; 6 import com.google.typography.font.sfntly.Font.MacintoshEncodingId;
7 import com.google.typography.font.sfntly.Font.UnicodeEncodingId; 7 import com.google.typography.font.sfntly.Font.UnicodeEncodingId;
8 import com.google.typography.font.sfntly.Font.WindowsEncodingId; 8 import com.google.typography.font.sfntly.Font.WindowsEncodingId;
9 import com.google.typography.font.sfntly.Tag; 9 import com.google.typography.font.sfntly.Tag;
10 import com.google.typography.font.sfntly.Font.PlatformId; 10 import com.google.typography.font.sfntly.Font.PlatformId;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 283
284 /** 284 /**
285 * Gets a list of Unicode blocks covered by the font and the amount each block 285 * Gets a list of Unicode blocks covered by the font and the amount each block
286 * is covered. 286 * is covered.
287 * 287 *
288 * @param font 288 * @param font
289 * the source font 289 * the source font
290 * @return a list of Unicode blocks covered by the font 290 * @return a list of Unicode blocks covered by the font
291 */ 291 */
292 // FIXME Find more elegant method of retrieving block data 292 // FIXME Find more elegant method of retrieving block data
293 // TODO Iterate by code points in the font. ICU UnicodeBlock does not support
yehh 2012/08/14 00:17:50 Will remove TODO comment for next version
294 // the retrieval of block names for each block, which makes this more
295 // complicated
296 public static DataDisplayTable listCharBlockCoverage(Font font) { 293 public static DataDisplayTable listCharBlockCoverage(Font font) {
297 String[] header = { "Block", "Coverage" }; 294 String[] header = { "Block", "Coverage" };
298 Align[] displayAlignment = { Align.Left, Align.Right }; 295 Align[] displayAlignment = { Align.Left, Align.Right };
299 DataDisplayTable table = new DataDisplayTable(Arrays.asList(header)); 296 DataDisplayTable table = new DataDisplayTable(Arrays.asList(header));
300 table.setAlignment(Arrays.asList(displayAlignment)); 297 table.setAlignment(Arrays.asList(displayAlignment));
301 298
302 // Iterate through each block to check for coverage 299 // Iterate through each block to check for coverage
303 CMap cmap = getUCSCMap(font); 300 CMap cmap = getUCSCMap(font);
304 int totalCount = 0; 301 int totalCount = 0;
305 for (int i = 0; i < UnicodeBlockData.numBlocks(); i++) { 302 for (int i = 0; i < UnicodeBlockData.numBlocks(); i++) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 scriptName, String.format("%d / %d", coveredScripts.get(scriptCode), s criptSet.size())})); 380 scriptName, String.format("%d / %d", coveredScripts.get(scriptCode), s criptSet.size())}));
384 } 381 }
385 if (unknown > 0) { 382 if (unknown > 0) {
386 table.add(Arrays.asList(new String[] {"Unsupported script", String.format( "%d", unknown)})); 383 table.add(Arrays.asList(new String[] {"Unsupported script", String.format( "%d", unknown)}));
387 } 384 }
388 385
389 return table; 386 return table;
390 } 387 }
391 388
392 /** 389 /**
393 * Gets a list of characters needed to fully scripts partially covered by the font 390 * Gets a list of characters needed to fully cover scripts partially covered b y the font
yehh 2012/08/13 23:40:15 "...fully cover..." Will fix for the next version
394 * 391 *
395 * @param font the source font 392 * @param font the source font
396 * @return a list of characters needed to fully cover partially-covered script s 393 * @return a list of characters needed to fully cover partially-covered script s
397 */ 394 */
398 public static DataDisplayTable listCharsNeededToCoverScript(Font font) { 395 public static DataDisplayTable listCharsNeededToCoverScript(Font font) {
399 String[] header = {"Script", "Code Point", "Name"}; 396 String[] header = {"Script", "Code Point", "Name"};
400 Align[] displayAlignment = {Align.Left, Align.Right, Align.Left}; 397 Align[] displayAlignment = {Align.Left, Align.Right, Align.Left};
401 DataDisplayTable table = new DataDisplayTable(Arrays.asList(header)); 398 DataDisplayTable table = new DataDisplayTable(Arrays.asList(header));
402 table.setAlignment(Arrays.asList(displayAlignment)); 399 table.setAlignment(Arrays.asList(displayAlignment));
403 HashMap<Integer, UnicodeSet> coveredScripts = new HashMap<Integer, UnicodeSe t>(); 400 HashMap<Integer, UnicodeSet> coveredScripts = new HashMap<Integer, UnicodeSe t>();
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 private static String getFormattedCodePointString(int codePoint) { 678 private static String getFormattedCodePointString(int codePoint) {
682 if (UCharacter.isValidCodePoint(codePoint)) { 679 if (UCharacter.isValidCodePoint(codePoint)) {
683 if (UCharacter.isBMP(codePoint)) { 680 if (UCharacter.isBMP(codePoint)) {
684 return String.format("U+%04X", codePoint); 681 return String.format("U+%04X", codePoint);
685 } 682 }
686 return String.format("U+%06X", codePoint); 683 return String.format("U+%06X", codePoint);
687 } 684 }
688 throw new IllegalArgumentException("Invalid code point " + codePoint); 685 throw new IllegalArgumentException("Invalid code point " + codePoint);
689 } 686 }
690 } 687 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b