Skip to content

Commit

Permalink
Validate presence of text-color and text-offset attributes
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Pastbin <[email protected]>
  • Loading branch information
pastk authored and vng committed Oct 14, 2023
1 parent 611abc0 commit 51864ce
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libkomwm.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ def addPattern(dashes):

all_draw_elements = set()

global validation_errors_count
for results in imapfunc(query_style, ((cl, classificator[cl], options.minzoom, options.maxzoom) for cl in class_order)):
for result in results:
cl, zoom, runtime_conditions, zstyle = result
Expand Down Expand Up @@ -820,13 +821,19 @@ def rule_sort_key(dict_):
dr_cur_subtext = dr_text.primary
for sp in has_text:
dr_cur_subtext.height = int(float(sp.get('font-size', "10").split(",")[0]))
if 'text-color' not in st:
print(f'ERROR: text-color not set for z{zoom} {cl}')
validation_errors_count += 1
dr_cur_subtext.color = mwm_encode_color(colors, sp, "text")
if st.get('text-halo-radius', 0) != 0:
dr_cur_subtext.stroke_color = mwm_encode_color(colors, sp, "text-halo", "white")
if 'text-offset' in sp or 'text-offset-y' in sp:
dr_cur_subtext.offset_y = int(sp.get('text-offset-y', sp.get('text-offset', 0)))
if 'text-offset-x' in sp:
elif 'text-offset-x' in sp:
dr_cur_subtext.offset_x = int(sp.get('text-offset-x', 0))
elif st.get('text-position', 'center') == 'center' and dr_element.symbol.priority:
print(f'ERROR: an icon is present, but caption\'s text-offset is not set for z{zoom} {cl}')
validation_errors_count += 1
if 'text' in sp and sp.get('text') not in ('name', 'int_name'):
dr_cur_subtext.text = sp.get('text')
if 'text-optional' in sp:
Expand Down

0 comments on commit 51864ce

Please sign in to comment.