Skip to content

Commit ac1ecce

Browse files
authored
Merge pull request #81 from gtt-project/ftr/cleanup-fonts
Better font management
2 parents 7d0fe7f + 7df0185 commit ac1ecce

18 files changed

+435
-288
lines changed

lib/redmine_gtt/hooks/view_layouts_base_html_head_hook.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class ViewLayoutsBaseHtmlHeadHook < Redmine::Hook::ViewListener
77
def view_layouts_base_html_head(context={})
88
tags = [];
99

10-
tags << stylesheet_link_tag("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css")
1110
tags << javascript_include_tag('main.js', :plugin => 'redmine_gtt')
1211
return tags.join("\n")
1312
end

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"homepage": "https://github.com/gtt-project/redmine_gtt#readme",
2222
"dependencies": {
23+
"font-awesome": "^4.7.0",
2324
"ol": "^6.5.0",
2425
"ol-ext": "^3.1.19"
2526
},

src/components/fontmaki-def.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/components/gtt-client.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,33 +1141,36 @@ export class GttClient {
11411141

11421142
reloadFontSymbol() {
11431143
if ('fonts' in document) {
1144-
(document as any).fonts.addEventListener('loadingdone', () => {
1145-
let loaded = false;
1146-
(document as any).fonts.forEach((font: any) => {
1147-
if (font.family === 'mcr-icons' || font.family === 'fontmaki') {
1148-
loaded = true
1149-
}
1150-
})
1151-
if (loaded) {
1152-
this.maps.forEach(m => {
1153-
const layers = m.getLayers()
1154-
layers.forEach(layer => {
1155-
if (layer instanceof VectorLayer &&
1156-
layer.getKeys().indexOf("title") >= 0 &&
1157-
layer.get("title") === "Features") {
1158-
const features = (layer as any).getSource().getFeatures()
1159-
const index = features.findIndex((feature: any) => {
1160-
return feature.getGeometry().getType() === "Point"
1161-
})
1162-
if (index >= 0) {
1163-
console.log("Reloading Features layer")
1164-
layer.changed()
1144+
const symbolFonts: Array<String> = []
1145+
for (const font in FontSymbol.prototype.defs.fonts) {
1146+
symbolFonts.push(font)
1147+
}
1148+
if (symbolFonts.length > 0) {
1149+
(document as any).fonts.addEventListener('loadingdone', (e: any) => {
1150+
const fontIndex = e.fontfaces.findIndex((font: any) => {
1151+
return symbolFonts.indexOf(font.family) >= 0
1152+
})
1153+
if (fontIndex >= 0) {
1154+
this.maps.forEach(m => {
1155+
const layers = m.getLayers()
1156+
layers.forEach(layer => {
1157+
if (layer instanceof VectorLayer &&
1158+
layer.getKeys().indexOf("title") >= 0 &&
1159+
layer.get("title") === "Features") {
1160+
const features = (layer as any).getSource().getFeatures()
1161+
const pointIndex = features.findIndex((feature: any) => {
1162+
return feature.getGeometry().getType() === "Point"
1163+
})
1164+
if (pointIndex >= 0) {
1165+
console.log("Reloading Features layer")
1166+
layer.changed()
1167+
}
11651168
}
1166-
}
1169+
})
11671170
})
1168-
})
1169-
}
1170-
})
1171+
}
1172+
})
1173+
}
11711174
}
11721175
}
11731176

src/components/gtt-setting.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const gtt_setting = ():void => {
1515
const selected = selectedValue === i
1616
element.append(new Option(i, i, selected, selected))
1717
if (selected) {
18-
element.nextElementSibling.className = i
18+
element.nextElementSibling.className = "fa " + i
1919
}
2020
}
2121
}
@@ -25,7 +25,7 @@ export const gtt_setting = ():void => {
2525
element.addEventListener('change', (ev) => {
2626
const currentTarget = ev.currentTarget as HTMLSelectElement
2727
const trackerId = currentTarget.id
28-
document.querySelector(`#icon_${trackerId}`).className = currentTarget.value
28+
document.querySelector(`#icon_${trackerId}`).className = "fa " + currentTarget.value
2929
})
3030
})
3131
}

src/components/mcricon-def.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/fonts/fontmaki2.ttf

57.5 KB
Binary file not shown.

src/fonts/fontmaki2.woff

35.5 KB
Binary file not shown.

src/fonts/fontmaki2.woff2

30.2 KB
Binary file not shown.

src/fonts/mcr-icons.ttf

-5.02 KB
Binary file not shown.

0 commit comments

Comments
 (0)