| 330 | self.fonts.append(font) |
| 331 | |
| 332 | def build_html(self, view, path, **kwargs): |
| 333 | b = self.context.b |
| 334 | b.comment('Start %s.%s\n' % (self.cssId, self.cssClass)) |
| 335 | b.div(cssId=self.cssId, cssClass=self.cssClass) |
| 336 | if self.fonts: |
| 337 | featureTable = self.fonts[0].ttFont.get('GSUB') |
| 338 | tags = [] |
| 339 | if self.defaultTags is not None: # Overwritten by defaults? |
| 340 | tags = self.defaultTags |
| 341 | elif featureTable is not None: |
| 342 | gsub = featureTable.table |
| 343 | for fs in gsub.FeatureList.FeatureRecord: |
| 344 | tags.append(fs.FeatureTag) |
| 345 | b.addHtml(''.join(tags)) |
| 346 | if tags: |
| 347 | if self.layoutType == self.LAYOUT_TAG_DESCRIPTION: |
| 348 | for tag in tags: |
| 349 | tagData = FONT_FEATURES.get(tag) |
| 350 | if tagData is None: |
| 351 | b.h5() |
| 352 | b.addHtml('Unknown tag: “%s”' % tag) |
| 353 | b._h5() |
| 354 | else: |
| 355 | b.h5() |
| 356 | b.addHtml('[%s] %s' % (tag, tagData['name'])) |
| 357 | b._h5() |
| 358 | b.addHtml(tagData['description']) |
| 359 | else: # self.LAYOUT_TAG_LIST |
| 360 | b.addHtml(', '.join(tags)) |
| 361 | else: |
| 362 | b.addHtml('No features defined (yet) in this font.') |
| 363 | else: |
| 364 | b.addHtml('No font selected.') |
| 365 | #b.addHtml(str(self.fonts[0].features)) |
| 366 | #b.addHtml(str(self.fontDataList)) |
| 367 | """ |
| 368 | for fontSize in self.fontSizes: |
| 369 | for fontName, _ in self.fontDataList: |
| 370 | style = "font-family:%s;font-size:%s;line-height:1.1em;height:%s;width:100%%;" % (fontName, px(fontSize), px(fontSize*1.1)) |
| 371 | style += "overflow:hidden;text-overflow:ellipsis;" |
| 372 | b.div(style=style) |
| 373 | b.addHtml('AaBbCcDdEe FfGgHhIiJjKk LlMmNnOoPp QqRrSsTtUu VvWwXxYyZz') #FfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz') |
| 374 | b._div() |
| 375 | """ |
| 376 | b._div() |
| 377 | b.comment('End %s.%s\n' % (self.cssId, self.cssClass)) |
| 378 | |
| 379 | class TypeGlyphSet(Group): |
| 380 | """Shows a list of type styles in their style. |