当前位置: 首页>>代码示例>>Java>>正文


Java HorizontalDeviceMetricsTable类代码示例

本文整理汇总了Java中com.google.typography.font.sfntly.table.core.HorizontalDeviceMetricsTable的典型用法代码示例。如果您正苦于以下问题:Java HorizontalDeviceMetricsTable类的具体用法?Java HorizontalDeviceMetricsTable怎么用?Java HorizontalDeviceMetricsTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HorizontalDeviceMetricsTable类属于com.google.typography.font.sfntly.table.core包,在下文中一共展示了HorizontalDeviceMetricsTable类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBasicHdmx

import com.google.typography.font.sfntly.table.core.HorizontalDeviceMetricsTable; //导入依赖的package包/类
public void testBasicHdmx() throws IOException {
  Font font = TestFontUtils.loadFont(TEST_FONT_FILE)[0];
  HorizontalDeviceMetricsTable hdmxTable = font.getTable(Tag.hdmx);
  assertEquals(0, hdmxTable.version());
  assertEquals(19, hdmxTable.numRecords());
  assertEquals(900, hdmxTable.recordSize());
  
  assertEquals(6, hdmxTable.pixelSize(0));
  assertEquals(7, hdmxTable.pixelSize(1));
  assertEquals(24, hdmxTable.pixelSize(18));
  
  assertEquals(7, hdmxTable.maxWidth(0));
  assertEquals(28, hdmxTable.maxWidth(18));
  
  assertEquals(4, hdmxTable.width(0, 0));  // .notdef
  assertEquals(4, hdmxTable.width(1, 0));
  assertEquals(5, hdmxTable.width(2, 0));
  assertEquals(14, hdmxTable.width(18, 0));

  assertEquals(4, hdmxTable.width(0, 36));  // A
  assertEquals(5, hdmxTable.width(1, 36));
  assertEquals(6, hdmxTable.width(2, 36));
  assertEquals(15, hdmxTable.width(18, 36));
}
 
开发者ID:witwall,项目名称:sfntly-java,代码行数:25,代码来源:HdmxTests.java

示例2: compress

import com.google.typography.font.sfntly.table.core.HorizontalDeviceMetricsTable; //导入依赖的package包/类
public byte[] compress(Font sfntlyFont) {
  MtxFontBuilder fontBuilder = new MtxFontBuilder();
  for (Map.Entry<Integer, ? extends Table> entry : sfntlyFont.tableMap().entrySet()) {
    Integer tag = entry.getKey();
    if (!REMOVE_TABLES.contains(tag)) {
      fontBuilder.addTable(tag, entry.getValue().readFontData());
    }
  }
  FontHeaderTable srcHead = sfntlyFont.getTable(Tag.head);
  fontBuilder.getHeadBuilder().initFrom(srcHead);

  GlyfEncoder glyfEncoder = new GlyfEncoder();
  glyfEncoder.encode(sfntlyFont);
  fontBuilder.addTableBytes(Tag.glyf, glyfEncoder.getGlyfBytes());
  fontBuilder.addTable(Tag.loca, null);

  ControlValueTable cvtTable = sfntlyFont.getTable(Tag.cvt);
  if (cvtTable != null) {
    CvtEncoder cvtEncoder = new CvtEncoder();
    cvtEncoder.encode(cvtTable);
    fontBuilder.addTableBytes(Tag.cvt, cvtEncoder.toByteArray());
  }

  HorizontalDeviceMetricsTable hdmxTable = sfntlyFont.getTable(Tag.hdmx);
  if (hdmxTable != null) {
    fontBuilder.addTable(Tag.hdmx, new HdmxEncoder().encode(sfntlyFont));
  }
  
  byte[] block1 = fontBuilder.build();
  byte[] block2 = glyfEncoder.getPushBytes();
  byte[] block3 = glyfEncoder.getCodeBytes();
  return packMtx(block1, block2, block3);
}
 
开发者ID:terro,项目名称:WCFont,代码行数:34,代码来源:MtxWriter.java

示例3: encode

import com.google.typography.font.sfntly.table.core.HorizontalDeviceMetricsTable; //导入依赖的package包/类
public WritableFontData encode(Font sourceFont) {
  HorizontalDeviceMetricsTable hdmx = sourceFont.getTable(Tag.hdmx);
  HorizontalMetricsTable hmtx = sourceFont.getTable(Tag.hmtx);
  MaximumProfileTable maxp = sourceFont.getTable(Tag.maxp);
  FontHeaderTable head = sourceFont.<FontHeaderTable>getTable(Tag.head);
  int unitsPerEm = head.unitsPerEm();
  int numRecords = hdmx.numRecords();
  int numGlyphs = maxp.numGlyphs();
  MagnitudeDependentWriter magWriter = new MagnitudeDependentWriter();
  for (int i = 0; i < numRecords; i++) {
    int ppem = hdmx.pixelSize(i);
    for (int j = 0; j < numGlyphs; j++) {
      int roundedTtAw =
          ((64 * ppem * hmtx.advanceWidth(j) + unitsPerEm / 2) / unitsPerEm + 32) / 64;
      int surprise = hdmx.width(i, j) - roundedTtAw;
      magWriter.writeValue(surprise);
    }
  }
  magWriter.flush();
  byte[] magBytes = magWriter.toByteArray();
  int resultSize = magBytes.length + HEADER_SIZE + RECORD_SIZE * numRecords;
  WritableFontData result = WritableFontData.createWritableFontData(resultSize);
  result.writeUShort(0, 0);
  result.writeUShort(2, numRecords);
  result.writeLong(4, hdmx.recordSize());
  for (int i = 0; i < numRecords; i++) {
    result.writeByte(HEADER_SIZE + RECORD_SIZE * i, (byte) hdmx.pixelSize(i));
    result.writeByte(HEADER_SIZE + RECORD_SIZE * i + 1, (byte) hdmx.maxWidth(i));
  }
  result.writeBytes(HEADER_SIZE + RECORD_SIZE * numRecords, magBytes);
  return result;
}
 
开发者ID:terro,项目名称:WCFont,代码行数:33,代码来源:HdmxEncoder.java

示例4: interRelateBuilders

import com.google.typography.font.sfntly.table.core.HorizontalDeviceMetricsTable; //导入依赖的package包/类
private static void
interRelateBuilders(Map<Integer, Table.Builder<? extends Table>> builderMap) {
  FontHeaderTable.Builder headerTableBuilder =
    (FontHeaderTable.Builder) builderMap.get(Tag.head);
  HorizontalHeaderTable.Builder horizontalHeaderBuilder =
    (HorizontalHeaderTable.Builder) builderMap.get(Tag.hhea);
  MaximumProfileTable.Builder maxProfileBuilder =
    (MaximumProfileTable.Builder) builderMap.get(Tag.maxp);
  LocaTable.Builder locaTableBuilder =
    (LocaTable.Builder) builderMap.get(Tag.loca);
  HorizontalMetricsTable.Builder horizontalMetricsBuilder =
    (HorizontalMetricsTable.Builder) builderMap.get(Tag.hmtx);
  HorizontalDeviceMetricsTable.Builder hdmxTableBuilder =
    (HorizontalDeviceMetricsTable.Builder) builderMap.get(Tag.hdmx);

  // set the inter table data required to build certain tables
  if (horizontalMetricsBuilder != null) {
    if (maxProfileBuilder != null) {
      horizontalMetricsBuilder.setNumGlyphs(maxProfileBuilder.numGlyphs());
    }
    if (horizontalHeaderBuilder != null) {
      horizontalMetricsBuilder.setNumberOfHMetrics(
          horizontalHeaderBuilder.numberOfHMetrics());
    }
  }

  if (locaTableBuilder != null) {
    if (maxProfileBuilder != null) {
      locaTableBuilder.setNumGlyphs(maxProfileBuilder.numGlyphs());
    }
    if (headerTableBuilder != null) {
      locaTableBuilder.setFormatVersion(headerTableBuilder.indexToLocFormat());
    }
  }

  if (hdmxTableBuilder != null) {
    if (maxProfileBuilder != null) {
      hdmxTableBuilder.setNumGlyphs(maxProfileBuilder.numGlyphs());
    }
  }      
}
 
开发者ID:terro,项目名称:WCFont,代码行数:42,代码来源:Font.java

示例5: interRelateBuilders

import com.google.typography.font.sfntly.table.core.HorizontalDeviceMetricsTable; //导入依赖的package包/类
private static void
interRelateBuilders(Map<Integer, Table.Builder<? extends Table>> builderMap) {
  FontHeaderTable.Builder headerTableBuilder =
    (FontHeaderTable.Builder) builderMap.get(Tag.head);
  HorizontalHeaderTable.Builder horizontalHeaderBuilder =
    (HorizontalHeaderTable.Builder) builderMap.get(Tag.hhea);
  VerticalHeaderTable.Builder verticalHeaderBuilder = 
    (VerticalHeaderTable.Builder) builderMap.get(Tag.vhea);
  MaximumProfileTable.Builder maxProfileBuilder =
    (MaximumProfileTable.Builder) builderMap.get(Tag.maxp);
  LocaTable.Builder locaTableBuilder =
    (LocaTable.Builder) builderMap.get(Tag.loca);
  HorizontalMetricsTable.Builder horizontalMetricsBuilder =
    (HorizontalMetricsTable.Builder) builderMap.get(Tag.hmtx);
  VerticalMetricsTable.Builder verticalMetricsBuilder = 
    (VerticalMetricsTable.Builder) builderMap.get(Tag.vmtx);
  HorizontalDeviceMetricsTable.Builder hdmxTableBuilder =
    (HorizontalDeviceMetricsTable.Builder) builderMap.get(Tag.hdmx);

  int numGlyphs = 0;
  if (locaTableBuilder != null) {
    if (headerTableBuilder != null) {
      locaTableBuilder.setFormatVersion(headerTableBuilder.indexToLocFormat());
    }
    if (locaTableBuilder.formatVersion() == IndexToLocFormat.shortOffset) {
        numGlyphs = locaTableBuilder.data().length() / 2 - 1;
    } else {
        numGlyphs = locaTableBuilder.data().length() / 4 - 1;
    }
  }
  
  if (maxProfileBuilder != null) {
    numGlyphs = maxProfileBuilder.numGlyphs();
  }
  
  // set the inter table data required to build certain tables
  if (horizontalMetricsBuilder != null) {
    horizontalMetricsBuilder.setNumGlyphs(numGlyphs);
    if (horizontalHeaderBuilder != null) {
      horizontalMetricsBuilder.setNumberOfHMetrics(
          horizontalHeaderBuilder.numberOfHMetrics());
    }
  }

  if (verticalMetricsBuilder != null) {
    verticalMetricsBuilder.setNumGlyphs(numGlyphs);
    if (verticalHeaderBuilder != null) {
      verticalMetricsBuilder.setNumberOfVMetrics(
          verticalHeaderBuilder.numberOfVMetrics());
    }
  }
  
  if (locaTableBuilder != null) {
    locaTableBuilder.setNumGlyphs(numGlyphs);
  }
  
  if (hdmxTableBuilder != null) {
      hdmxTableBuilder.setNumGlyphs(numGlyphs);
  }      
}
 
开发者ID:jtanx,项目名称:sfntly-java-mod,代码行数:61,代码来源:Font.java


注:本文中的com.google.typography.font.sfntly.table.core.HorizontalDeviceMetricsTable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。