xref: /aosp_15_r20/external/noto-fonts/scripts/adjust_vertical_metrics.py (revision e5825d3be9fd13b272e7df556d285d1f07f3b027)
1*e5825d3bSAndroid Build Coastguard Worker#!/usr/bin/python
2*e5825d3bSAndroid Build Coastguard Worker#
3*e5825d3bSAndroid Build Coastguard Worker# Copyright 2016 Google Inc. All rights reserved.
4*e5825d3bSAndroid Build Coastguard Worker#
5*e5825d3bSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
6*e5825d3bSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
7*e5825d3bSAndroid Build Coastguard Worker# You may obtain a copy of the License at
8*e5825d3bSAndroid Build Coastguard Worker#
9*e5825d3bSAndroid Build Coastguard Worker#     http://www.apache.org/licenses/LICENSE-2.0
10*e5825d3bSAndroid Build Coastguard Worker#
11*e5825d3bSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
12*e5825d3bSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
13*e5825d3bSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*e5825d3bSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
15*e5825d3bSAndroid Build Coastguard Worker# limitations under the License.
16*e5825d3bSAndroid Build Coastguard Worker
17*e5825d3bSAndroid Build Coastguard Worker"""Adjust the vertical metrics of the fonts for Android."""
18*e5825d3bSAndroid Build Coastguard Worker
19*e5825d3bSAndroid Build Coastguard Workerimport glob
20*e5825d3bSAndroid Build Coastguard Workerfrom fontTools import ttLib
21*e5825d3bSAndroid Build Coastguard Worker
22*e5825d3bSAndroid Build Coastguard Workerdef main():
23*e5825d3bSAndroid Build Coastguard Worker    """Change the ascent and descent of Noto Serif fonts."""
24*e5825d3bSAndroid Build Coastguard Worker    for font_file in glob.glob('NotoSerif-*.ttf'):
25*e5825d3bSAndroid Build Coastguard Worker        font = ttLib.TTFont(font_file)
26*e5825d3bSAndroid Build Coastguard Worker        font['hhea'].ascent = 1900
27*e5825d3bSAndroid Build Coastguard Worker        font['hhea'].descent = -500
28*e5825d3bSAndroid Build Coastguard Worker        font.save('touched/'+font_file)
29*e5825d3bSAndroid Build Coastguard Worker
30*e5825d3bSAndroid Build Coastguard Workerif __name__ == '__main__':
31*e5825d3bSAndroid Build Coastguard Worker    main()
32*e5825d3bSAndroid Build Coastguard Worker
33