| 1 | /* |
|---|
| 2 | * Copyright 2007-2008, Plutext Pty Ltd. |
|---|
| 3 | * |
|---|
| 4 | * This file is part of docx4j. |
|---|
| 5 | |
|---|
| 6 | docx4j is licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 7 | you may not use this file except in compliance with the License. |
|---|
| 8 | |
|---|
| 9 | You may obtain a copy of the License at |
|---|
| 10 | |
|---|
| 11 | http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 12 | |
|---|
| 13 | Unless required by applicable law or agreed to in writing, software |
|---|
| 14 | distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 16 | See the License for the specific language governing permissions and |
|---|
| 17 | limitations under the License. |
|---|
| 18 | |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | package org.docx4j.fonts; |
|---|
| 22 | |
|---|
| 23 | public class FontUtils { |
|---|
| 24 | |
|---|
| 25 | public final static java.lang.CharSequence target = (new String("%20")).subSequence(0, 3); |
|---|
| 26 | public final static java.lang.CharSequence replacement = (new String(" ")).subSequence(0, 1); |
|---|
| 27 | |
|---|
| 28 | public static String pathFromURL(String path) { |
|---|
| 29 | |
|---|
| 30 | if (path.startsWith("file:/")) { |
|---|
| 31 | if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") > -1) { |
|---|
| 32 | path = path.substring(6); |
|---|
| 33 | } else { |
|---|
| 34 | path = path.substring(5); |
|---|
| 35 | } |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | // Convert %20 to spaces |
|---|
| 39 | if (path.indexOf("%20")>-1) { |
|---|
| 40 | |
|---|
| 41 | path = path.toString().replace(target, replacement); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | return path; |
|---|
| 45 | |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | } |
|---|