Skip to content

Commit

Permalink
[new feature]: Fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom MacWright committed Dec 15, 2010
1 parent 10fef53 commit 7023a33
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
23 changes: 23 additions & 0 deletions client/css/tilemill.css
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,29 @@ a.inspect-unique.active { background-color:#222; }
-webkit-border-radius:3px 0px 0px 0px;
}

/**
* Font pallette
*/
#fonts {
padding-left:70px;
position:relative;
float:left;
}

#fonts label {
text-shadow:#000 0px -1px 0px;
position:absolute;
left:300px;
font-size:11px;
font-weight:bold;
text-transform:uppercase;
}

#fonts-list {
position:absolute;
left:350px;
}

/**
* Popup editor.
*/
Expand Down
7 changes: 7 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ <h4 id='zoom-display'>Zoom level ?</h4>
<input size='7' maxlength='7' id='color' type='text' class='text' />
<div class='pane' id='farbtastic'></div>
</div>
<div id='fonts'>
<label>Fonts</label>
<select id='fonts-list'></select>
</div>
<div id='colors'>
<label>Colors</label>
<div></div>
Expand Down Expand Up @@ -322,6 +326,9 @@ <h2><%= title %></h2>
</form>
</div>
</script>
<script type="text/html" name="font">
<option><%= font %>
</script>
<script type="text/html" name="popup-message">
<div id='popup-message' class='clearfix pane <%= type %>'>
<%= content %>
Expand Down
13 changes: 12 additions & 1 deletion client/js/includes/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ TileMill.backend.rasterizers.tilelive.datasource = function(datab64, callback) {
}
};

/**
* Retrieve available fonts on a map server.
*/
TileMill.backend.rasterizers.tilelive.fonts = function(callback) {
TileMill.backend.runtime.get({
url: TileMill.settings.tileliveServer.split(',')[0] +
'abilities.json',
success: callback
});
};

/**
* Retrieve fields for a given b64 encoded MML url.
*/
Expand Down Expand Up @@ -245,7 +256,7 @@ $.each(['list', 'get', 'post', 'del', 'url', 'mtime'], function(i, func) {
TileMill.backend.servers[TileMill.settings.server][func];
});

$.each(['datasource', 'fields', 'values', 'servers', 'status'], function(i, func) {
$.each(['datasource', 'fields', 'values', 'servers', 'status', 'fonts'], function(i, func) {
TileMill.backend[func] =
TileMill.backend.rasterizers[TileMill.settings.rasterizer][func];
});
18 changes: 18 additions & 0 deletions client/js/includes/stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ TileMill.stylesheet.init = function() {
// Add stylesheets in order.
var queue = new TileMill.queue();

TileMill.stylesheet.initFonts();

var s = TileMill.mml.parseMML(TileMill.data.mml).stylesheets;
for (var i in s) {
var src = s[i];
Expand Down Expand Up @@ -53,6 +55,22 @@ TileMill.stylesheet.init = function() {
return stylesheets;
};

TileMill.stylesheet.initFonts = function() {
TileMill.backend.fonts(function(abilities) {
_.map(abilities.fonts, function(font) {
$('#fonts-list').append(TileMill.template('font', {
font: font
}));
});
$('#fonts-list').change(function() {
var position = TileMill.mirror.cursorPosition();
TileMill.mirror.insertIntoLine(
position.line,
position.character, '"' + $(this).val() + '"');
});
});
};

/**
* Add a stylesheet to the page
*/
Expand Down

0 comments on commit 7023a33

Please sign in to comment.