Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1#!/usr/bin/env python32 3import collections4import json5import parse_tfm6import subprocess7import sys8 9 10def find_font_path(font_name):11 try:12 font_path = subprocess.check_output(['kpsewhich', font_name])13 except OSError:14 raise RuntimeError("Couldn't find kpsewhich program, make sure you" +15 " have TeX installed")16 except subprocess.CalledProcessError:17 raise RuntimeError("Couldn't find font metrics: '%s'" % font_name)18 return font_path.strip()19 20 21def main():22 mapping = json.load(sys.stdin)23 24 fonts = [25 'cmbsy10.tfm',26 'cmbx10.tfm',27 'cmbxti10.tfm',28 'cmex10.tfm',29 'cmmi10.tfm',30 'cmmib10.tfm',31 'cmr10.tfm',32 'cmsy10.tfm',33 'cmti10.tfm',34 'msam10.tfm',35 'msbm10.tfm',36 'eufm10.tfm',37 'cmtt10.tfm',38 'rsfs10.tfm',39 'cmss10.tfm',40 'cmssbx10.tfm',41 'cmssi10.tfm',42 ]43 44 # Extracted by running `\font\a=<font>` and then `\showthe\skewchar\a` in45 # TeX, where `<font>` is the name of the font listed here. The skewchar46 # will be printed out in the output. If it outputs `-1`, that means there47 # is no skewchar, so we use `None` here.48 font_skewchar = {49 'cmbsy10': None,50 'cmbx10': None,51 'cmbxti10': None,52 'cmex10': None,53 'cmmi10': 127,54 'cmmib10': None,55 'cmr10': None,56 'cmsy10': 48,57 'cmti10': None,58 'msam10': None,59 'msbm10': None,60 'eufm10': None,61 'cmtt10': None,62 'rsfs10': None,63 'cmss10': None,64 'cmssbx10': None,65 'cmssi10': None,66 }67 68 font_name_to_tfm = {}69 70 for font_name in fonts:71 font_basename = font_name.split('.')[0]72 font_path = find_font_path(font_name)73 font_name_to_tfm[font_basename] = parse_tfm.read_tfm_file(font_path)74 75 families = collections.defaultdict(dict)76 77 for family, chars in mapping.items():78 for char, char_data in chars.items():79 char_num = int(char)80 81 font = char_data['font']82 tex_char_num = int(char_data['char'])83 yshift = float(char_data['yshift'])84 85 if family == "Script-Regular":86 tfm_char = font_name_to_tfm[font].get_char_metrics(tex_char_num,87 fix_rsfs=True)88 else:89 tfm_char = font_name_to_tfm[font].get_char_metrics(tex_char_num)90 91 height = round(tfm_char.height + yshift / 1000.0, 5)92 depth = round(tfm_char.depth - yshift / 1000.0, 5)93 italic = round(tfm_char.italic_correction, 5)94 width = round(tfm_char.width, 5)95 96 skewkern = 0.097 if (font_skewchar[font] and98 font_skewchar[font] in tfm_char.kern_table):99 skewkern = round(100 tfm_char.kern_table[font_skewchar[font]], 5)101 102 families[family][char_num] = {103 'height': height,104 'depth': depth,105 'italic': italic,106 'skew': skewkern,107 'width': width108 }109 110 sys.stdout.write(111 json.dumps(families, separators=(',', ':'), sort_keys=True))112 113if __name__ == '__main__':114 main()115 